import { createBrowserRouter, Navigate } from 'react-router-dom'

import Login from '../pages/Login'
import Main from '../pages/main'
import Home from '../pages/Home'
import Mall from '../pages/Mall'
import Mall1 from '../pages/Mall/Mall1'
import Mall2 from '../pages/Mall/Mall2'
import Mall3 from '../pages/Mall/Mall3'
import User from '../pages/User'
import PageOne from '../pages/Other/pageOne'
import PageTwo from '../pages/Other/pageTwo'

const routes = [
  {
    path: '/',
    Component: Main,
    children: [
      // 重定向
      {
        path: '/',
        element: <Navigate to="home" replace/>
      },
      {
        path: 'home',
        Component: Home
      },
      {
        path: 'mall',
        Component: Mall
      },
      {
        path: 'mall1',
        Component: Mall1
      },
      {
        path: 'mall2',
        Component: Mall2
      },
      {
        path: 'mall3',
        Component: Mall3
      },
      {
        path: 'user',
        Component: User
      },
       {
        path: 'other',
        children: [
          {
            path: 'pageOne',
            Component: PageOne
          },
          {
            path: 'pageTwo',
            Component: PageTwo
          }
        ]
      },
    ]
  },
  {
    path: 'login',
    Component: Login
  }
]

export default createBrowserRouter(routes)